home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / p4 / p4-1_2b.lha / p4-1.2b / contrib_f / comm_slave.f < prev    next >
Text File  |  1992-10-19  |  2KB  |  94 lines

  1.       subroutine fslave()
  2.  
  3.       include 'p4f.h'
  4.  
  5.       real a(600000)
  6.       integer type, from, next, procid, length, numsl, retcde, recvlen
  7.       integer tagcnt, tagdat, tagend, done
  8.       parameter (tagcnt = 10)
  9.       parameter (tagdat = 20)
  10.       parameter (tagend = 30)
  11.  
  12.       numsl = p4ntotids() - 1
  13.       procid = p4myid()
  14.       print *,'slave ',procid,' has started'
  15.       call p4flush()
  16.       if (procid .eq. numsl) then
  17.          next = 0
  18.       else
  19.          next = procid + 1
  20.       endif
  21.       length = 8
  22.       type = tagcnt
  23.       from = -1
  24.       call p4recv(type,from,n,length,recvlen,retcde)
  25.       print *,'SLAVE ',procid,' received from = ',from,' type = ',type
  26.       call p4flush()
  27.  
  28. c Initialize socket connections between the slaves 
  29.       type = tagcnt
  30.       from = -1
  31.       call p4recv(type,from,a,length,recvlen,retcde)
  32.       call p4sendr(tagcnt,next,a,recvlen,retcde)
  33.  
  34.       length = 600000
  35. c
  36.       if (procid .eq. 1) then
  37.          do 10 i = 6,19
  38.             do 11 k = 1,n
  39.       type = i
  40.       from = -1
  41.       call p4recv(type,from,a,length,recvlen,retcde)
  42. 11          continue
  43. 10       continue
  44.          do 22 i = 6,19
  45.             do 21 k = 1,n
  46.       type = i
  47.       from = -1
  48.       call p4recv(type,from,a,length,recvlen,retcde)
  49. 21          continue
  50. 22       continue
  51.          do 23 i = 6,19
  52.             do 24 k = 1,n
  53.       type = i
  54.       from = -1
  55.       call p4recv(type,from,a,length,recvlen,retcde)
  56.       call p4send(i,0,a,recvlen,retcde)
  57. 24          continue
  58. 23       continue
  59.          do 27 i = 6,19
  60.             do 28 k = 1,n
  61.       type = i
  62.       from = -1
  63.       call p4recv(type,from,a,length,recvlen,retcde)
  64.       done = p4clock()
  65.       call p4send(i,0,done,4,retcde)
  66. 28          continue
  67. 27       continue
  68.       endif
  69. c
  70.       do 30 i = 6,19
  71.          do 31 k = 1,n
  72.       type = i
  73.       from = -1
  74.       call p4recv(type,from,a,length,recvlen,retcde)
  75.       call p4send(i,next,a,recvlen,retcde)
  76. 31       continue
  77. 30    continue
  78. c
  79.       do 40 i = 6,19
  80.          do 41 k = 1,n
  81.       type = i
  82.       from = -1
  83.       call p4recv(type,from,a,length,recvlen,retcde)
  84. 41       continue
  85. 40    continue
  86. c
  87.       length = 0
  88.       type = tagend
  89.       from = 0
  90.       call p4recv(type,from,a,length,recvlen,retcde)
  91. 999   print *,'Slave ',procid,' has been cleaned up'
  92.       call p4flush()
  93.       end
  94.